package org.aurora.core.server.scheduler.processor;

import org.aurora.core.server.scheduler.Scheduler;
import org.aurora.model.request.ReportTaskRequest;
import org.aurora.model.response.CommonResponse;
import org.aurora.remote.AbstractRemoteProcessor;

import java.util.List;

public class ClientReportTaskProcessor extends AbstractRemoteProcessor<ReportTaskRequest, CommonResponse> {

    private Scheduler scheduler;

    public ClientReportTaskProcessor(Scheduler scheduler) {
        this.scheduler = scheduler;
    }

    @Override
    public CommonResponse doProcessor(ReportTaskRequest request) {
        String appcode = request.getAppcode();
        String ip = request.getIp();
        int port = request.getPort();
        List<String> taskNames = request.getTaskNames();

        this.scheduler.registerClientTask(ip, port, appcode, taskNames);
        return CommonResponse.buildSuccess();
    }
}
